<!DOCTYPE html>
<html>
  <head>
    <title>dasTeam proudly presents -- dasDing</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <link href="resources/frameworks/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="resources/frameworks/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <link rel="stylesheet" href="resources/css/jquery-ui.css" />
    <link href="resources/css/layout.css" rel="stylesheet">
    <link href="resources/css/base.css" rel="stylesheet">
    <link href="resources/css/widgets/profiles.css" rel="stylesheet">
    <link href="resources/css/widgets/search.css" rel="stylesheet">

    <script src="resources/frameworks/bootstrap/js/bootstrap.min.js"></script>
    <script src='resources/js/lib/jquery-1.9.1.js'></script>
    <script src='resources/js/lib/jquery-ui-1.10.3.custom.min'></script>
    <script src='resources/js/lib/mustache.js'></script>
    <script src='resources/frameworks/openlayers/OpenLayers.js'></script>
    <script src='resources/js/src/config.js'></script>
    <script src='resources/js/src/documentready.js'></script>
    <script src='resources/js/src/utils.js'></script>    
  </head>

  <body>
    <div class="container-narrow">
      <div class="masthead">
        <h3 class="muted">dasDing</h3>

        <div id="main_nav_container" class="mustache_container">
        </div>
      </div>
      <!-- <div class="jumbotron"></div> -->
      <hr>
        

      <div class="container-fluid">
        <div class="row-fluid">
          <div class="span12">
            <h4>Profildetails</h4>
                <div id='dd_profile_container' class="mustache_container">
                </div>

          </div>
        </div>
      </div>


        <hr>
        <!-- #include virtual="components/common/footer.html" -->

    </div>

<script>
 $(document).ready(function(){

    var view = {
      'config' : {
        'currentpage' : { 
          'profilepage' : 'true'
        }
      },
      "profiledata" : {}
    };

    if($.urlParam('new') && $.urlParam('new') == "true") {
      view.profiledata = dasding.prototypes.profile_prototype;
      view['profiledata']['new_form'] = "true";   
      view['profiledata']['editable'] = "true";   
      display_profile();
    } else if($.urlParam('edit') && $.urlParam('edit') == "true") {
      $.getJSON('resources/dummy/user', function(data) {
        view['profiledata'] = data;
        view['profiledata']['edit_form'] = "true";   
        view['profiledata']['editable'] = "true";   
        display_profile();
      });
    } else {
      $.getJSON('resources/dummy/user', function(data) {
        view['profiledata'] = data;
        display_profile();
      });
    }
    function display_profile() {
      $("body").append("<div id='mustache_profiletemp' style='display:none'>");
      $("#mustache_profiletemp").load("components/widgets/profile.html #mustache_dd_profile",function(){
        var template = document.getElementById('mustache_dd_profile').innerHTML;
        var output = Mustache.render(template, view);
        $("#dd_profile_container").html(output);
        $("#mustache_profiletemp").remove();
      });
      $("body").delegate(".dd_edit_button", "click",  function() {
        $("#dd_profile_details").addClass("editable");
      });

    }


    // load mainnav
    $("body").append("<div id='mustache_navtemp' style='display:none'>");
    $("#mustache_navtemp").load("components/navigation/mainnav.html #mustache_navbar",function(){
      var template = document.getElementById('mustache_navbar').innerHTML;
      var output = Mustache.render(template, view);
      $("#main_nav_container").html(output);
      $("#mustache_navtemp").remove();
    });


  });
</script>


</html>